package com.yds.modewithprinceple.singleton;

/**
 * @author YDS
 * @date 2021/5/7
 * @discribe 静态内部类
 *
 * 1、构造函数用private修饰，外部无法访问
 * 2、使用的时候即调用getInstance的时候才初始化
 * 3、静态常量，保证了单例的唯一性
 */
public class SingletonInternalClass {
    private SingletonInternalClass() {
    }

    public static SingletonInternalClass getInstance() {
        return SafeMode.instance;
    }

    private static class SafeMode {
        private static final SingletonInternalClass instance = new SingletonInternalClass();
    }
}
